package com.android.demp;


import android.view.View;
import android.view.animation.DecelerateInterpolator;
import android.widget.TextView;

public final class SwapViews implements Runnable {
private boolean mIsFirstView;
TextView text1;
TextView text2;

public SwapViews(boolean isFirstView, TextView text1, TextView text2) {
 mIsFirstView = isFirstView;
 this.text1 = text1;
 this.text2 = text2;
}

public void run() {
 final float centerX = text1.getWidth() / 2.0f;
 final float centerY = text2.getHeight() / 2.0f;
 Flip3dAnimation rotation;

 if (mIsFirstView) {
	 text1.setVisibility(View.GONE);
	 text2.setVisibility(View.VISIBLE);
	 text2.requestFocus();

     rotation = new Flip3dAnimation(-90, 0, centerX, centerY);
 } else {
	 text2.setVisibility(View.GONE);
	 text1.setVisibility(View.VISIBLE);
	 text1.requestFocus();

     rotation = new Flip3dAnimation(90, 0, centerX, centerY);
 }

 rotation.setDuration(500);
 rotation.setFillAfter(true);
 rotation.setInterpolator(new DecelerateInterpolator());

 if (mIsFirstView) {
	 text2.startAnimation(rotation);
 } else {
	 text1.startAnimation(rotation);
 }
}
}
